<template>
  <div class="login">
    <div class="title">新能源车联网综合大数据平台</div>
    <div class="login-form">
      <el-form ref="form" :model="form" :rules="rules">
        <el-form-item prop="username">
          <el-input
            v-model="form.username"
            placeholder="账号"
            prefix-icon="el-icon-user"
            @keyup.native.enter="login"
          />
        </el-form-item>
        <el-form-item prop="password">
          <el-input
            v-model="form.password"
            type="password"
            placeholder="密码"
            prefix-icon="el-icon-view"
            @keyup.native.enter="login"
          />
        </el-form-item>
        <el-form-item class="btn-group">
          <el-button :loading="loading" @click="login">登录</el-button>
          <el-button :loading="loading" @click="register">注册</el-button>
        </el-form-item>
      </el-form>
    </div>
    <a href="/#/about" class="footer">车联网大数据平台</a>
    <ul class="bg-bubbles">
      <li/>
      <li/>
      <li/>
      <li/>
      <li/>
      <li/>
      <li/>
      <li/>
      <li/>
      <li/>
    </ul>
     
  </div>
</template>

<script>
// import { register, login } from '@/api/app'
// import { randArray } from '@/utils/pwdAES'

export default {
  name: 'Login',
  data() {
    return {
      form: {
        username: '',
        password: ''
      },
      loading: false,
      rules: {
        username: [
          { required: true, message: '用户名不能为空', trigger: 'blur' }
        ],
        password: [
          { required: true, message: '密码不能为空', trigger: 'blur' }
        ]
      }
    }
  },
  methods: {
    login() {
       this.$router.push({ path: '/index' })
      // this.$refs.form.validate(valid => {
      //   if (valid) {
      //     this.loading = true
      //     login({ name: this.form.username, password: this.form.password }).then(res => {
      //       this.loading = false
      //       // 简单随机数，代表token
      //       const token = randArray()
      //       this.$store.dispatch('Login', token)
      //       this.$router.push({ path: '/' })
      //     }).catch(err => {
      //       this.loading = false
      //     })
      //   }
      // })
    },

    register() {
      console.log('注册')
      this.$router.push({ path: '/register' })
    }
  }
}
</script>

<style lang="scss" scoped>
.login {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  opacity: 0.8;
  background-image: linear-gradient(to bottom right, #2A3263 0%, #17ACED 100%);
  overflow: hidden;
}

.title {
  position: fixed;
  bottom: calc(50% + 180px);
  right: 0;
  left: 0;
  font-size: 48px;
  text-align: center;
  color: white;
  font-weight: 500;
  letter-spacing: 5px;
}

.login-form {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: auto;
  padding: 10px;
  border-radius: 4px;
  /* background-image: linear-gradient(to right bottom, #75d2b7, #63dab8, #50deb4); */
  box-shadow: 0 0 2px 0px #75d5b6;

  .el-form {
    padding: 10px;
    width: 382px;
  }

  ::v-deep.el-input__inner {
    border: 1px solid rgba(255, 255, 255, 0.4);
    background-color: rgba(255, 255, 255, 0.85);
  }

  ::v-deep.el-form-item__error {
    color: #de1010;
  }

  .btn-group  {
    margin-top: 60px;

    ::v-deep.el-form-item__content {
      display: flex;
      justify-content: space-between;

      .el-button {
        width: 50%;
        border: 1px solid rgba(255, 255, 255, 0.4);
        background-color: rgba(255, 255, 255, 0.2);
        color: white;

        &:hover {
          background-color: rgba(255, 255, 255, 0.3);
        }
      }
    }
  }
}

.footer {
  position: fixed;
  left: 0px;
  bottom: 0px;
  margin: 10px 0;
  width: 100%;
  color: #776464;
  text-align: center;
  font-size: 12px;
  text-decoration: none;
}

.bg-bubbles {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;

  li {
    position: absolute;
    list-style: none;
    display: block;
    width: 40px;
    height: 40px;
    background-color: rgba(255, 255, 255, 0.15);
    bottom: -160px;
    animation: square 25s infinite;
    transition-timing-function: linear;

    &:nth-child(1) {
      left: 10%;
    }

    &:nth-child(2) {
      left: 20%;
      width: 80px;
      height: 80px;
      animation-delay: 2s;
      animation-duration: 17s;
    }

    &:nth-child(3) {
      left: 25%;
      animation-delay: 4s;
    }

    &:nth-child(4) {
      left: 40%;
      width: 60px;
      height: 60px;
      animation-duration: 22s;
      background-color: rgba(255, 255, 255, 0.25);
    }

    &:nth-child(5) {
      left: 70%;
    }

    &:nth-child(6) {
      left: 80%;
      width: 120px;
      height: 120px;
      animation-delay: 3s;
      background-color: rgba(255, 255, 255, 0.2);
    }

    &:nth-child(7) {
      left: 32%;
      width: 160px;
      height: 160px;
      animation-delay: 7s;
    }

    &:nth-child(8) {
      left: 55%;
      width: 20px;
      height: 20px;
      animation-delay: 15s;
      animation-duration: 40s;
    }

    &:nth-child(9) {
      left: 25%;
      width: 10px;
      height: 10px;
      animation-delay: 2s;
      animation-duration: 40s;
      background-color: rgba(255, 255, 255, 0.3);
    }

    &:nth-child(10) {
      left: 90%;
      width: 160px;
      height: 160px;
      animation-delay: 11s;
    }
  }
}

@keyframes square {
  0% {
    transform: translateY(0);
  }
  100% {
    transform: translateY(-700px) rotate(600deg);
  }
}
</style>
